﻿using SRB.Tg.DrawingStandard;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Teigha.DatabaseServices;
using Teigha.Geometry;

namespace SRB.Tg.Model
{
    /// <summary>
    /// 承台
    /// </summary>
    public class PileCap : MemberBase
    {
        PileCapParameter _pileCapPara;      
        public double Length, Width, Height;
        List<double> ArrAlongW, ArrAlongL, ArrAlongH;
        List<double> ArrAlongWE, ArrAlongLE, ArrAlongHV;//宽对应架立筋，长对应架立筋，高对应水平筋
        eRebarDia _N1Dia; eRebarDia _N2Dia; eRebarDia _N3Dia; eRebarDia _N4Dia;
        int bottomNum = 2;
        double bottomSapce = 15 * 10;
        double pileDepth = 13 * 10;
        double radius = 0.6*0.5 ;
        int t2bSapce = 15 * 10;
        int t2bSapceW = 15 * 10;
        int t2bSapceL = 15 * 10;
        int sideSapce = 15 * 10;
        int vSp =60 * 10;
        int eSp = 60 * 10;
        double pileDia = 40*10;  //桩径
        Dictionary<int, int> dicNo = new Dictionary<int, int>();
        /// <summary>
        /// 承台，单位毫米。
        /// </summary>
        /// <param name="l"></param>
        /// <param name="w"></param>
        /// <param name="h"></param>
        /// <param name="cover"></param>
        public PileCap(double l,double w, double h,double cover,eRebarDia N1Dia,eRebarDia N2Dia,eRebarDia N3Dia, eRebarDia N4Dia,double scale)// 
        {
            Length = l;
            Width = w;
            Height = h;
            CoverThk = cover;
            _N1Dia = N1Dia;
            _N2Dia = N2Dia;
            _N3Dia = N3Dia;
            _N4Dia = N4Dia;
          
            #region 配置钢筋           

            //double NetWidthForN1 = Length - 2 * CoverThk - 2*radius* scale;
            //double NetWidthForN2 = Width - 2 * CoverThk  - 2 * radius * scale;
            //double NetWidthForN3 = Height - CoverThk - bottomSapce * (bottomNum-1)- pileDepth- radius * scale;
            double NetWidthForN1 = Length - 2 * CoverThk - GeneralRebar.outerDia[N3Dia];
            double NetWidthForN2 = Width - 2 * CoverThk- GeneralRebar.outerDia[N3Dia];
            double NetWidthForN3 = Height - CoverThk - bottomSapce * (bottomNum - 1) - pileDepth - GeneralRebar.outerDia[N1Dia]/2;

            ArrAlongW = RebarArrangement.ArrangeT2BRebar(NetWidthForN2, t2bSapce); //横桥向
            ArrAlongL = RebarArrangement.ArrangeT2BRebar(NetWidthForN1, t2bSapce);  //顺桥向
            ArrAlongH = RebarArrangement.ArrangeSideRebar(NetWidthForN3, sideSapce); // 侧面
           
            ArrAlongHV = new List<double>(); //水平筋
            ArrAlongWE = new List<double>(); // 横桥向架立筋
            ArrAlongLE = new List<double>(); //顺桥向架立筋

            #region 计算架立筋和水平筋算法 
            double total = 0, totalhalf = 0, totalAll=0;
            bool isComputer = false;
            if (Height/10 > 300)
            {
                totalAll = ArrAlongH.Sum();
                for (int i = 0; i < ArrAlongH.Count; i++)
                {
                    total += ArrAlongH[i];
                    totalhalf += ArrAlongH[i];
                    if (totalhalf >= totalAll / 2)
                    {
                        if (i != ArrAlongH.Count - 1)
                        {
                            if (total >= vSp / 3 && total <= vSp * 2 / 3)
                            {
                                ArrAlongHV.Add(total);
                                isComputer = true;
                            }
                        }
                        totalhalf = 0;
                    }
                    int num = vSp / sideSapce;
                    if (i % num == num - 1)
                    {
                        if (i != 0 && isComputer)
                        {
                            ArrAlongHV.Add(vSp - ArrAlongHV[ArrAlongHV.Count - 1]);
                            isComputer = false;
                        }
                        else
                            ArrAlongHV.Add(total);
                        total = 0;
                    }
                }
            }

            total = 0;
            totalhalf = 0;
            totalAll = ArrAlongW.Sum();
            isComputer = false;
            for (int i=0;i< ArrAlongW.Count;i++)
            {
                total += ArrAlongW[i];
                totalhalf += ArrAlongW[i];
                if(totalhalf>= totalAll / 2)
                {
                    if (i != ArrAlongW.Count - 1)
                    {
                        if (total >= eSp / 3 && total <= eSp * 2 / 3)
                        {
                            ArrAlongWE.Add(total);
                            isComputer = true;
                        }
                    }
                    totalhalf = 0;
                }               
                int num = eSp / t2bSapce;
                if (i % num==num-1)
                {
                    if(i!=0&& isComputer)
                    {
                        ArrAlongWE.Add(eSp - ArrAlongWE[ArrAlongWE.Count - 1]);
                        isComputer = false;
                    }
                    else
                      ArrAlongWE.Add(total);
                    total = 0;
                }
            }
            total = 0;
            totalhalf = 0;
            isComputer = false;
            totalAll = ArrAlongL.Sum();
            for (int i=0;i<ArrAlongL.Count;i++)
            {
                total += ArrAlongL[i];
                totalhalf += ArrAlongL[i];
                if (totalhalf >= totalAll / 2)
                {
                    if (i != ArrAlongL.Count - 1)
                    {
                        if (total >= eSp / 3 && total <= eSp * 2 / 3)
                        {
                            ArrAlongLE.Add(total);
                            isComputer = true;
                        }
                    }
                    totalhalf = 0;
                }
                int num = eSp / t2bSapce;
                if (i % num == num - 1)
                {
                    if (i != 0 && isComputer)
                    {
                        ArrAlongLE.Add(eSp - ArrAlongLE[ArrAlongLE.Count-1]);
                        isComputer = false;
                    }
                    else
                        ArrAlongLE.Add(total);
                   total = 0;                    
                }
            }
            #endregion
            #endregion
        }

        public PileCap(PileCapParameter selectPara)// 
        {
            _pileCapPara = selectPara;
            InitPileNo();
            Length = selectPara.L;
            Width = selectPara.W;
            Height = selectPara.H;
            CoverThk = selectPara.Cover;
            _N1Dia = selectPara.N1;
            _N2Dia = selectPara.N2;
            _N3Dia = selectPara.N5;
            _N4Dia = selectPara.N4;
            bottomNum = selectPara.bottomNum;
            bottomSapce = selectPara.t2bSapceL;
            pileDepth = selectPara.pileDepth;           
            t2bSapceL = selectPara.t2bSapceL;
            t2bSapceW = selectPara.t2bSapceW;
            sideSapce = selectPara.sideSapceH;
            string vSpstring = selectPara.vSp;
            string eSpstring = selectPara.eSp;
            vSp = 60 * 10;
            eSp = 60 * 10;
            if (!string.IsNullOrWhiteSpace(vSpstring))
                vSp = int.Parse(vSpstring.Split('*')[0]);
            if (!string.IsNullOrWhiteSpace(eSpstring))
                eSp = int.Parse(eSpstring.Split('*')[0]);
        
            #region 配置钢筋           

            //double NetWidthForN1 = Length - 2 * CoverThk - 2*radius* scale;
            //double NetWidthForN2 = Width - 2 * CoverThk  - 2 * radius * scale;
            //double NetWidthForN3 = Height - CoverThk - bottomSapce * (bottomNum-1)- pileDepth- radius * scale;
            double NetWidthForN1 = Length - 2 * CoverThk - GeneralRebar.outerDia[selectPara.N5];
            double NetWidthForN2 = Width - 2 * CoverThk - GeneralRebar.outerDia[selectPara.N5];
            double NetWidthForN3 = Height - CoverThk - bottomSapce * (bottomNum - 1) - pileDepth - GeneralRebar.outerDia[selectPara.N1]*0.5;

            ArrAlongW = RebarArrangement.ArrangeT2BRebar(NetWidthForN2, t2bSapceW); //横桥向
            ArrAlongL = RebarArrangement.ArrangeT2BRebar(NetWidthForN1, t2bSapceL);  //顺桥向
            ArrAlongH = RebarArrangement.ArrangeSideRebar(NetWidthForN3, sideSapce); // 侧面

            ArrAlongHV = new List<double>(); //水平筋
            ArrAlongWE = new List<double>(); // 横桥向架立筋
            ArrAlongLE = new List<double>(); //顺桥向架立筋

            #region 计算架立筋和水平筋算法 
            double total = 0, totalhalf = 0, totalAll = 0;
            bool isComputer = false;
            if (Height / 10 > 300)
            {
                totalAll = ArrAlongH.Sum();
                for (int i = 0; i < ArrAlongH.Count; i++)
                {
                    total += ArrAlongH[i];
                    totalhalf += ArrAlongH[i];
                    //if (totalhalf >= totalAll / 2)
                    //{
                    //    if (i != ArrAlongH.Count - 1)
                    //    {
                    //        if (total >= vSp / 3 && total <= vSp * 2 / 3)
                    //        {
                    //            ArrAlongHV.Add(total);
                    //            isComputer = true;
                    //        }
                    //    }
                    //    totalhalf = 0;
                    //}
                    int num = vSp / sideSapce;
                    if (i % num == num - 1)
                    {
                        if (i != 0 && isComputer)
                        {
                            ArrAlongHV.Add(vSp - ArrAlongHV[ArrAlongHV.Count - 1]);
                            isComputer = false;
                        }
                        else
                            ArrAlongHV.Add(total);
                        total = 0;
                    }
                }
            }

            total = 0;
            totalhalf = 0;
            totalAll = ArrAlongW.Sum();
            isComputer = false;
            for (int i = 0; i < ArrAlongW.Count; i++)
            {
                total += ArrAlongW[i];
                totalhalf += ArrAlongW[i];
                //if (totalhalf >= totalAll / 2)
                //{
                //    if (i != ArrAlongW.Count - 1)
                //    {
                //        if (total >= eSp / 3 && total <= eSp * 2 / 3)
                //        {
                //            ArrAlongWE.Add(total);
                //            isComputer = true;
                //        }
                //    }
                //    totalhalf = 0;
                //}
                int num = eSp / t2bSapceW;
                if (i % num == num - 1)
                {
                    if (i != 0 && isComputer)
                    {
                        ArrAlongWE.Add(eSp - ArrAlongWE[ArrAlongWE.Count - 1]);
                        isComputer = false;
                    }
                    else
                        ArrAlongWE.Add(total);
                    total = 0;
                }
            }
            total = 0;
            totalhalf = 0;
            isComputer = false;
            totalAll = ArrAlongL.Sum();
            for (int i = 0; i < ArrAlongL.Count; i++)
            {
                total += ArrAlongL[i];
                totalhalf += ArrAlongL[i];
                if (totalhalf >= totalAll / 2)
                {
                    if (i != ArrAlongL.Count - 1)
                    {
                        if (total >= eSp / 3 && total <= eSp * 2 / 3)
                        {
                            ArrAlongLE.Add(total);
                            isComputer = true;
                        }
                    }
                    totalhalf = 0;
                }
                int num = eSp / t2bSapceL;
                if (i % num == num - 1)
                {
                    if (i != 0 && isComputer)
                    {
                        ArrAlongLE.Add(eSp - ArrAlongLE[ArrAlongLE.Count - 1]);
                        isComputer = false;
                    }
                    else
                        ArrAlongLE.Add(total);
                    total = 0;
                }
            }
            #endregion
            #endregion
        }

        /// <summary>
        /// 编号处理算法
        /// </summary>
        private void InitPileNo()
        {
            //1-12号钢筋的编号
            int No = 2;
            dicNo = new Dictionary<int, int>();
            for(int i=1;i<13;i++)
            {
                dicNo.Add(i, i);
            }
            if (_pileCapPara.N1 == _pileCapPara.N3)
            {
                dicNo[3] = dicNo[1];
            }
            else
            {
                No++;
                dicNo[3] = No;
            }
            if (_pileCapPara.N2 == _pileCapPara.N4)
            {
                dicNo[4] = dicNo[2];
            }
            else
            {
                No++;
                dicNo[4] = No;
            }
            No++;
            dicNo[5] = No;
            No++;
            dicNo[6] = No;
            No++;
            dicNo[7] = No;
            if (_pileCapPara.N8 != eRebarDia.None)
            {
            //    dicNo[8] = dicNo[5];
            //}
            //else
            //{
                No++;
                dicNo[8] = No;
            }
            if(_pileCapPara.N9!=eRebarDia.None)
            {
                No++;
                dicNo[9] = No;
            }
            if (_pileCapPara.N10 != eRebarDia.None)
            {
                No++;
                dicNo[10] = No;
            }
            #region 逻辑有问题（参考后台的,应该是存在就添加）
            if (_pileCapPara.N11 != eRebarDia.None)
            {
                //if (_pileCapPara.N1 != _pileCapPara.N11)
                //{
                    No++;
                    dicNo[11] = No;
                //}
                //else
                //{
                //    dicNo[11] = dicNo[1];
                //}
            }
            if (_pileCapPara.N12 != eRebarDia.None)
            {
                //if (_pileCapPara.N2 != _pileCapPara.N12)
                //{
                    No++;
                    dicNo[12] = No;
                //}
                //else
                //{
                //    dicNo[12] = dicNo[2];
                //}
            }
            #endregion
        }
        /// <summary>
        /// 渲染图形
        /// </summary>
        /// <param name="scale"></param>
        public void DrawingPileCap(Database db, int OverAllScale, 
            System.Data.DataTable dt1, System.Data.DataTable dt2)
        {
            #region 绘制图形
            Extents2d ExtEF, ExtAB, ExtCD, ExtDetail;
            Point2d RefPtAB, RefPtCD, RefPtEF, RefPtDetail;



            RefPtAB = Point2d.Origin;
            PlotElevationA(ref db, out ExtAB, RefPtAB, OverAllScale);
            //BaseShapePloter.RenderEntity(db, ExtAB.ConvertPL());

            RefPtCD = RefPtAB.C2D(420 * 0.5 * OverAllScale);        
            PlotElevationB(ref db, out ExtCD, RefPtCD, OverAllScale);
            //BaseShapePloter.RenderEntity(db, ExtCD.ConvertPL());

            RefPtEF = RefPtAB.C2D(0, -297 * OverAllScale);        
            PlotPlan(ref db, out ExtEF, RefPtEF, OverAllScale);
            //BaseShapePloter.RenderEntity(db, ExtEF.ConvertPL());

            RefPtDetail = RefPtEF.C2D(420 * 0.5 * OverAllScale);
            RendeDetail(ref db, RefPtDetail, out ExtDetail, dt1, dt2,OverAllScale);

            //BaseShapePloter.RenderEntity(db, ExtDetail.ConvertPL());
            #endregion
            #region 模型空间到布局空间投影处理
            LayoutTools.CreateLayout4Div(db, "图纸", ExtAB, ExtCD, ExtEF, ExtDetail,
               Extensions.leftWidth, 5, Extensions.bottomHeight, 10, OverAllScale,false);
            #endregion
        }

        /// <summary>
        /// 绘制A
        /// </summary>
        /// <param name="db"></param>
        /// <param name="ext"></param>
        /// <param name="insertPoint"></param>
        /// <param name="scale"></param>
        public void PlotElevationA(ref Database db, out Extents2d ext, Point2d insertPoint, int scale)
        {
            double LA = 0;
            ext = new Extents2d(insertPoint, insertPoint);
            TextPloter.AddTitle(db,insertPoint, ref ext, "A-A(顺桥向)", string.Format("(1:{0:G})", scale),  scale);
            //TextPloter.PrintScaleText(db, insertPoint.C2D(Width / 4, 0), "1/2 SECTION B-B", string.Format("(1:{0:G})", scale), ref ext, scale, Extensions.curFont);

            Point2d CT = insertPoint;
            Point2d M1 = CT.C2D(0, -20 * scale);

            PLPloter.AddPloy4(db, M1, 0.5 * Length, 0.5 * Length, Height,ref ext,"H细线");

            #region  钢筋网
            //List<double> ArrAlongLB = new List<double>();
            double firstspace = 0;
            //for(int i=0;i< ArrAlongL.Count;i++)
            //{
            //    if (i == 0 || i == ArrAlongL.Count - 1)
            //    {
            //        ArrAlongLB.Add(bottomSapce);
            //        firstspace = ArrAlongL[0];
            //    }
            //    else
            //        ArrAlongLB.Add(ArrAlongL[i]);
            //}
            if (_pileCapPara.N11 != eRebarDia.None)
            {
                RebarPLPloter.CreateSingleLineHatch(db, ref ext, M1.C2D(-0.5 * Length + CoverThk, -Height + pileDepth - 2 * radius * scale),
                     radius, ArrAlongL, scale, GeneralRebar.outerDia[_pileCapPara.N5]);
            }
            #endregion

            #region  底层钢筋
            if (bottomNum > 0)
            {
                for (int i = 0; i < bottomNum; i++)
                {
                    RebarPLPloter.CreateSingleLineHatch(db, ref ext, M1.C2D(-0.5 * Length + CoverThk, -Height+bottomSapce*i+ pileDepth),
                      radius, ArrAlongL, scale, GeneralRebar.outerDia[_pileCapPara.N5]);
                }
            }
            #endregion

            #region  顶层钢筋
            RebarPLPloter.CreateSingleLineHatch(db, ref ext, M1.C2D(-0.5 * Length + CoverThk,-CoverThk),
                    radius, ArrAlongL, scale, GeneralRebar.outerDia[_pileCapPara.N5]);
            #endregion

            #region  侧面钢筋
            RebarPLPloter.CreateSideSingleLineHatch(db, ref ext, M1.C2D(-0.5 * Length + CoverThk, -Height + pileDepth+ bottomSapce*(bottomNum-1)),
                  radius, ArrAlongH, scale, GeneralRebar.outerDia[_pileCapPara.N1], bottomSapce * (bottomNum - 1));
            RebarPLPloter.CreateSideSingleLineHatch(db, ref ext, M1.C2D(0.5 * Length - CoverThk, -Height + pileDepth + bottomSapce * (bottomNum - 1)),
                 radius, ArrAlongH, scale, GeneralRebar.outerDia[_pileCapPara.N1], bottomSapce * (bottomNum - 1),false);
            #endregion

            #region  架立钢筋
            if(ArrAlongLE.Count>0)
            {
                double L = 0;
                foreach (var item in ArrAlongLE)
                {
                    L += item;
                    PLPloter.AddLine(db,M1.C2D(-0.5 * Length + CoverThk+ L,-CoverThk), M1.C2D(-0.5 * Length + CoverThk+ L, -Height + pileDepth), ref ext, "H粗线");
                }
            }
            #endregion

            #region  水平支撑钢筋钢筋
            if (ArrAlongHV.Count > 0)
            {
                double L = 0;
                foreach (var item in ArrAlongHV)
                {
                    L += item;
                    PLPloter.AddLine(db,M1.C2D(-0.5 * Length + CoverThk, -Height + pileDepth + L), M1.C2D(0.5 * Length - CoverThk, -Height + pileDepth + L), ref ext, "H粗线");
                }
            }
            #endregion

            #region 承台联接柱体
            //PLPloter.CreateCylindricalSection(db, ref ext, M1.C3D(), Width / (10 * scale), 8, true, scale);
            RebarPLPloter.CreateCylindricalSection(db, ref ext, M1.C3D(-Length / 4, -Height+ pileDepth), pileDia /(scale), 800, false, scale);
            RebarPLPloter.CreateCylindricalSection(db, ref ext, M1.C3D(Length / 4, -Height+ pileDepth), pileDia / (scale), 800, false, scale);
            #endregion

            #region 钢筋编号
            double width = 0;
            width = ArrAlongW.Sum();
            List<double> lList = new List<double>();
            for(int i=0;i<bottomNum;i++)
            {
                if(i< bottomNum-1)
                 lList.Add(bottomSapce);
                else
                    lList.Add(0);
            }
            List<double> wList = new List<double>();
            for (int i = 1; i < ArrAlongW.Count; i++)
            {
                wList.Add(ArrAlongW[i]);
            }
            //1
            RebarPLPloter.CreateLineArrowDB(db, ref ext, M1.C3D(0, -Height + pileDepth + bottomSapce * (bottomNum - 1)), ArrowDirection.North, lList, wList, dicNo[1].ToString(), scale, true, 4);
            RebarPLPloter.CreateLineArrowDB(db, ref ext, M1.C3D(Length / 5, -CoverThk), ArrowDirection.South, new List<double>(), wList, dicNo[3].ToString(), scale,true,2);
            //3
            RebarPLPloter.CreateLineArrowDB(db, ref ext, M1.C3D(Length / 2 -CoverThk,-Height/2), ArrowDirection.West, new List<double>(), new List<double>(), dicNo[5].ToString(), scale);
            RebarPLPloter.CreateLineArrowDB(db, ref ext, M1.C3D(-Length / 2 + CoverThk, -Height / 2), ArrowDirection.East, new List<double>(), new List<double>(), dicNo[5].ToString(), scale);
            //4
            RebarPLPloter.CreateLineArrowDB(db, ref ext, M1.C3D(-Length / 2 + CoverThk, -Height / 3), ArrowDirection.East, new List<double>(), ArrAlongLE, dicNo[8].ToString(), scale,false);
            //2
            LA = 0;
            List<Point3d> bottomPtsR = new List<Point3d>();
            bottomPtsR.Add(M1.C3D(-Length / 2 + CoverThk + GeneralRebar.outerDia[_pileCapPara.N5] / 2, radius * scale - CoverThk));
            //bottomPtsR.Add(M1.C3D(Length / 2 - CoverThk - radius * scale, radius * scale - CoverThk));
            for (int i = 0; i < ArrAlongL.Count; i++)
            {
                double item = ArrAlongL[i];
                LA += item;
                if (i < ArrAlongL.Count - 1)
                    bottomPtsR.Add(M1.C3D(-Length / 2 + CoverThk + LA + GeneralRebar.outerDia[_pileCapPara.N5] / 2, radius * scale - CoverThk));
                else
                    bottomPtsR.Add(M1.C3D(-Length / 2 + CoverThk + LA + GeneralRebar.outerDia[_pileCapPara.N5] / 2, radius * scale - CoverThk));
            }
            bottomPtsR.Sort((x, y) => x.X.CompareTo(y.X));
            RebarPLPloter.CreateRebarPointLine(db, ref ext, eDirection.E_BOTTOM, bottomPtsR, dicNo[4].ToString(), 4,3, scale);
            LA = 0;
            bottomPtsR = new List<Point3d>();
            bottomPtsR.Add(M1.C3D(-Length / 2 + CoverThk + GeneralRebar.outerDia[_pileCapPara.N5] / 2, -Height + pileDepth + bottomSapce * (bottomNum - 1) + scale * radius));
            //bottomPtsR.Add(M1.C3D(Length / 2 - CoverThk - radius * scale, radius * scale - CoverThk));
            for (int i = 0; i < ArrAlongL.Count; i++)
            {
                double item = ArrAlongL[i];
                bottomPtsR.Add(bottomPtsR[bottomPtsR.Count - 1].C3D(item));

                //LA += item;
                //if (i < ArrAlongW.Count - 1)
                //    bottomPtsR.Add(M1.C3D(-Width / 2 + CoverThk + LA + radius * scale, -Height + pileDepth + bottomSapce * (bottomNum - 1) + scale * radius));
                //else
                //    bottomPtsR.Add(M1.C3D(-Width / 2 + CoverThk + LA + radius * scale, -Height + pileDepth + bottomSapce * (bottomNum - 1) + scale * radius));
            }
            bottomPtsR.Sort((x, y) => x.X.CompareTo(y.X));
            RebarPLPloter.CreateBottomRebarPointLine(db, ref ext, bottomPtsR, bottomNum, bottomSapce, dicNo[2].ToString(), 4, 3, scale);
            //7
            LA = 0;
            bottomPtsR = new List<Point3d>();
            bottomPtsR.Add(M1.C3D(-0.5 * Length + CoverThk+ GeneralRebar.outerDia[_pileCapPara.N5] / 2, -Height + pileDepth - 2 * radius * scale + radius * scale));
            //bottomPtsR.Add(M1.C3D(Length / 2 - CoverThk - radius * scale, radius * scale - CoverThk));
            for (int i = 0; i < ArrAlongL.Count; i++)
            {
                double item = ArrAlongL[i];
                bottomPtsR.Add(bottomPtsR[bottomPtsR.Count - 1].C3D(item));
            }
            bottomPtsR.Sort((x, y) => x.X.CompareTo(y.X));
            if (_pileCapPara.N11 != eRebarDia.None)
            {
                RebarPLPloter.CreateRebarPointLine(db, ref ext, eDirection.E_TOP, bottomPtsR, dicNo[11].ToString(), 4, 3, scale, true);
            }
            LA = 0;
            bottomPtsR = new List<Point3d>();
            bottomPtsR.Add(M1.C3D(-0.5 * Length + CoverThk + radius * scale, -Height + pileDepth + bottomSapce * (bottomNum - 1) + GeneralRebar.outerDia[_pileCapPara.N1] / 2));
            for (int i = 0; i < ArrAlongH.Count-1; i++)
            {
                double item = ArrAlongH[i];
                bottomPtsR.Add(bottomPtsR[bottomPtsR.Count - 1].C3D(0,item));
            }
            bottomPtsR.Sort((x, y) => y.Y.CompareTo(x.Y));
            bottomPtsR.RemoveAt(bottomPtsR.Count-1);
            RebarPLPloter.CreateRebarPointLine(db, ref ext, eDirection.E_RIGHT, bottomPtsR, dicNo[6].ToString(), 2, 0, scale);
            LA = 0;
            bottomPtsR = new List<Point3d>();
            bottomPtsR.Add(M1.C3D(0.5 * Length - CoverThk - radius * scale, -Height + pileDepth + bottomSapce * (bottomNum - 1) + GeneralRebar.outerDia[_N1Dia] / 2));
            //bottomPtsR.Add(M1.C3D(Length / 2 - CoverThk - radius * scale, radius * scale - CoverThk));
            for (int i = 0; i < ArrAlongH.Count - 1; i++)
            {
                double item = ArrAlongH[i];
                bottomPtsR.Add(bottomPtsR[bottomPtsR.Count - 1].C3D(0, item));
            }
            bottomPtsR.Sort((x, y) => y.Y.CompareTo(x.Y));
            bottomPtsR.RemoveAt(bottomPtsR.Count - 1);
            RebarPLPloter.CreateRebarPointLine(db, ref ext, eDirection.E_LEFT, bottomPtsR, dicNo[6].ToString(), 2, 0, scale);
            #endregion

            #region 标注
            List<Point3d> leftPts = new List<Point3d>(), topPts = new List<Point3d>();
            topPts.Add(M1.C3D(-Length / 2));
            topPts.Add(M1.C3D(-Length / 2 + CoverThk + GeneralRebar.outerDia[_pileCapPara.N5] / 2));
            //topPts.Add(M1.C3D(Length / 2 - CoverThk - GeneralRebar.outerDia[_N3Dia] / 2));
            topPts.Add(M1.C3D(Length / 2));
            LA = 0;
            for (int i = 0; i < ArrAlongL.Count; i++)
            {
                double item = ArrAlongL[i];
                LA += item;
                topPts.Add(M1.C3D(-Length / 2 + CoverThk + LA + GeneralRebar.outerDia[_pileCapPara.N5] / 2));
                //if(i< ArrAlongL.Count-1)
                //  topPts.Add(M1.C3D(-Length / 2 + CoverThk  + LA + GeneralRebar.outerDia[_N3Dia] / 2));
                //else
                //    topPts.Add(M1.C3D(-Length / 2 + CoverThk + LA -2* GeneralRebar.outerDia[_N3Dia] / 2));
            }
            topPts.Sort((x, y) => x.X.CompareTo(y.X));

            DimPloter.AddDoubleListDimRotated(db, ref ext, topPts[0].C3D(0, 10 * scale), topPts, scale, 0, t2bSapceL, ArrowDirection.North, Unit.Millimeter,Unit.Centimeter);

            leftPts.Add(M1.C3D(-Length / 2, 0));
            leftPts.Add(M1.C3D(-Length / 2, -CoverThk + GeneralRebar.outerDia[_pileCapPara.N1] * 0.5));
            leftPts.Add(M1.C3D(-Length / 2, -Height + pileDepth + GeneralRebar.outerDia[_pileCapPara.N1] * 0.5));
            leftPts.Add(M1.C3D(-Length / 2, -Height));
            for (int i = 1; i < bottomNum; i++)
            {
                leftPts.Add(M1.C3D(-Length / 2, -Height + pileDepth + GeneralRebar.outerDia[_pileCapPara.N1] * 0.5 + bottomSapce * i));
            }

            LA = 0;
            for (int i = 0; i < ArrAlongH.Count; i++)
            {
                double item = ArrAlongH[i];
                LA += item;

                leftPts.Add(M1.C3D(-Length / 2, -Height + pileDepth + bottomSapce * (bottomNum - 1) + LA + GeneralRebar.outerDia[_pileCapPara.N1] * 0.5));

            }
            leftPts.Sort((x, y) => x.Y.CompareTo(y.Y));

            List<Point3d> listBottom = new List<Point3d>();
            for (int i = 0; i < bottomNum + 2; i++)
            {
                listBottom.Add(leftPts[i]);
            }
            DimPloter.AddListDimRotated(db, ref ext, leftPts[0].C3D(-8 * scale), listBottom, scale, 90, 1,  Unit.Millimeter, Unit.Centimeter);
            DimPloter.AddListDimRotated(db, ref ext, leftPts[0].C3D(-8 * scale),
                 new List<Point3d>() { leftPts[bottomNum + 1], leftPts[leftPts.Count - 4] }, scale, 90, sideSapce, Unit.Millimeter, Unit.Centimeter);
            DimPloter.AddListDimRotated(db, ref ext, leftPts[0].C3D(-8 * scale),
                new List<Point3d>() { leftPts[leftPts.Count - 1], leftPts[leftPts.Count - 2], leftPts[leftPts.Count - 4] }, scale, 90, 1, Unit.Millimeter, Unit.Centimeter);
            DimPloter.AddListDimRotated(db, ref ext, leftPts[0].C3D(-8 * scale - 5 * scale),
                new List<Point3d>() { M1.C3D(0, -Height), M1.C3D() }, scale, 90, 1,Unit.Millimeter, Unit.Centimeter);

            #endregion
        }
        /// <summary>
        /// 绘制B
        /// </summary>
        /// <param name="db"></param>
        /// <param name="ext"></param>
        /// <param name="insertPoint"></param>
        /// <param name="scale"></param>
        public void PlotElevationB(ref Database db, out Extents2d ext, Point2d insertPoint, int scale)
        {
            ext = new Extents2d(insertPoint, insertPoint);
            TextPloter.AddTitle(db, insertPoint, ref ext, "B-B(横桥向)", string.Format("(1:{0:G})", scale), scale);
            //TextPloter.PrintScaleText(db, insertPoint.C2D(Length / 4, 0), "1/2 SECTION D-D", string.Format("(1:{0:G})", scale), ref ext, scale, Extensions.curFont);
            Point2d CT = insertPoint;
            Point2d M1 = CT.C2D(0, -20 * scale);

            PLPloter.AddPloy4(db, M1, 0.5 * Width, 0.5 * Width, Height, ref ext, "H细线");

      
            #region  钢筋网
            //List<double> ArrAlongWB = new List<double>();
            double firstspace = 0;
            //for (int i = 0; i < ArrAlongW.Count; i++)
            //{
            //    if (i == 0 || i == ArrAlongW.Count - 1)
            //    {
            //        ArrAlongWB.Add(bottomSapce);
            //        firstspace = ArrAlongW[0];
            //    }
            //    else
            //        ArrAlongWB.Add(ArrAlongW[i]);
            //}
            if (_pileCapPara.N12 != eRebarDia.None)
            {
                RebarPLPloter.CreateSingleLineHatch(db, ref ext, M1.C2D(-0.5 * Width + CoverThk, -Height + pileDepth - 2 * radius * scale),
                     radius, ArrAlongW, scale, GeneralRebar.outerDia[_pileCapPara.N5], false);
            }
            #endregion

            #region  底层钢筋
            if (bottomNum > 0)
            {
                for (int i = 0; i < bottomNum; i++)
                {
                    RebarPLPloter.CreateSingleLineHatch(db, ref ext, M1.C2D(-0.5 * Width + CoverThk, -Height + bottomSapce * i + pileDepth),
                      radius, ArrAlongW, scale, GeneralRebar.outerDia[_pileCapPara.N5],false);
                }
            }
            #endregion

            #region  顶层钢筋
            RebarPLPloter.CreateSingleLineHatch(db, ref ext, M1.C2D(-0.5 * Width + CoverThk, -CoverThk),
                    radius, ArrAlongW, scale, GeneralRebar.outerDia[_pileCapPara.N5],false);
            #endregion

            #region  侧面钢筋
            RebarPLPloter.CreateSideSingleLineHatch(db, ref ext, M1.C2D(-0.5 * Width + CoverThk, -Height + pileDepth + bottomSapce * (bottomNum - 1)),
                  radius, ArrAlongH, scale, GeneralRebar.outerDia[_pileCapPara.N1], bottomSapce * (bottomNum - 1),true,"H粗线");
            RebarPLPloter.CreateSideSingleLineHatch(db, ref ext, M1.C2D(0.5 * Width - CoverThk, -Height + pileDepth + bottomSapce * (bottomNum - 1)),
                 radius, ArrAlongH, scale, GeneralRebar.outerDia[_pileCapPara.N1], bottomSapce * (bottomNum - 1), false, "H粗线");
            #endregion

            #region  架立钢筋
            if (ArrAlongWE.Count > 0)
            {
                double L = 0;
                for (int i=0;i<ArrAlongWE.Count-1;i++)
                {
                    L += ArrAlongWE[i];
                    PLPloter.AddLine(db,M1.C2D(-0.5 * Width + CoverThk + L, -CoverThk), M1.C2D(-0.5 * Width + CoverThk + L, -Height + pileDepth), ref ext, "H细线");
                }
            }
            #endregion

            #region  水平支撑钢筋钢筋
            if (ArrAlongHV.Count > 0)
            {
                double L = 0;
                foreach (var item in ArrAlongHV)
                {
                    L += item;
                    PLPloter.AddLine(db,M1.C2D(-0.5 * Width + CoverThk , -Height + pileDepth + L), M1.C2D(0.5 * Width - CoverThk, -Height + pileDepth + L), ref ext, "H细线");
                }
            }
            #endregion

            #region 承台联接柱体
            //PLPloter.CreateCylindricalSection(db, ref ext, M1.C3D(), Width / (10 * scale), 8, true, scale);
            RebarPLPloter.CreateCylindricalSection(db, ref ext, M1.C3D(-Width / 4, -Height + pileDepth), pileDia / (scale), 800, false, scale);
            RebarPLPloter.CreateCylindricalSection(db, ref ext, M1.C3D(Width / 4, -Height + pileDepth), pileDia / (scale), 800, false, scale);
            #endregion

            #region 钢筋编号
            double width = 0;
            width = ArrAlongW.Sum();
            List<double> lList = new List<double>();
            for (int i = 0; i < bottomNum; i++)
            {
                if (i < bottomNum - 1)
                    lList.Add(bottomSapce);
                else
                    lList.Add(0);
            }
            List<double> wList = new List<double>();
            for (int i = 1; i < ArrAlongW.Count; i++)
            {
                wList.Add(ArrAlongW[i]);
            }
            //2
            RebarPLPloter.CreateLineArrowDB(db, ref ext, M1.C3D(0, -Height + pileDepth + bottomSapce * (bottomNum - 1)), ArrowDirection.North, lList, wList, dicNo[2].ToString(), scale, true, 5);
            RebarPLPloter.CreateLineArrowDB(db, ref ext, M1.C3D(Width / 5, -CoverThk), ArrowDirection.South, new List<double>(), wList, dicNo[4].ToString(), scale,true,2);

            RebarPLPloter.CreateLineArrowDB(db, ref ext, M1.C3D(Width / 2 - CoverThk, -Height / 2), ArrowDirection.West, new List<double>(), new List<double>(), dicNo[5].ToString(), scale);
            RebarPLPloter.CreateLineArrowDB(db, ref ext, M1.C3D(-Width / 2 + CoverThk, -Height / 2), ArrowDirection.East, new List<double>(), new List<double>(), dicNo[5].ToString(), scale);

            //1
            double LA = 0;
            List<Point3d> bottomPtsR = new List<Point3d>();
            //bottomPtsR.Add(M1.C3D(-Width / 2 + CoverThk + radius * scale, -radius * scale - CoverThk));
            bottomPtsR.Add(M1.C3D(-Width / 2 + CoverThk + GeneralRebar.outerDia[_pileCapPara.N5]*0.5, -radius * scale - CoverThk));
            //bottomPtsR.Add(M1.C3D(Length / 2 - CoverThk - radius * scale, radius * scale - CoverThk));
            for (int i = 0; i < ArrAlongW.Count; i++)
            {
                double item = ArrAlongW[i];
                LA += item;
                if (i < ArrAlongW.Count - 1)
                    bottomPtsR.Add(M1.C3D(-Width / 2 + CoverThk + LA + GeneralRebar.outerDia[_pileCapPara.N5]*0.5, -radius * scale - CoverThk));
                else
                    bottomPtsR.Add(M1.C3D(-Width / 2 + CoverThk + LA + GeneralRebar.outerDia[_pileCapPara.N5] *0.5, -radius * scale - CoverThk));
            }
            bottomPtsR.Sort((x, y) => x.X.CompareTo(y.X));
            RebarPLPloter.CreateRebarPointLine(db, ref ext, eDirection.E_BOTTOM, bottomPtsR, dicNo[3].ToString(), 3, 2, scale);
            LA = 0;
            bottomPtsR = new List<Point3d>();
            bottomPtsR.Add(M1.C3D(-Width / 2 + CoverThk + GeneralRebar.outerDia[_pileCapPara.N5]*0.5, -Height + pileDepth + bottomSapce * (bottomNum - 1) -   scale * radius));
            //bottomPtsR.Add(M1.C3D(Length / 2 - CoverThk - radius * scale, radius * scale - CoverThk));
            for (int i = 0; i < ArrAlongW.Count; i++)
            {
                //double item = ArrAlongL[i];
                //bottomPtsR.Add(bottomPtsR[bottomPtsR.Count - 1].C3D(item));

                double item = ArrAlongW[i];
                LA += item;
                if (i < ArrAlongW.Count - 1)
                    bottomPtsR.Add(M1.C3D(-Width / 2 + CoverThk + LA + GeneralRebar.outerDia[_pileCapPara.N5]*0.5, -Height + pileDepth + bottomSapce * (bottomNum - 1) - scale * radius));
                else
                    bottomPtsR.Add(M1.C3D(-Width / 2 + CoverThk + LA + GeneralRebar.outerDia[_pileCapPara.N5]*0.5, -Height + pileDepth + bottomSapce * (bottomNum - 1) - scale * radius));
            }
            bottomPtsR.Sort((x, y) => x.X.CompareTo(y.X));
            RebarPLPloter.CreateBottomRebarPointLine(db, ref ext, bottomPtsR,bottomNum,bottomSapce, dicNo[1].ToString(), 3, 2, scale);
            //7
            LA = 0;
            bottomPtsR = new List<Point3d>();
            bottomPtsR.Add(M1.C3D(-Width / 2 + CoverThk + GeneralRebar.outerDia[_pileCapPara.N5]*0.5, -Height + pileDepth - 2 * radius * scale - radius * scale));
            //bottomPtsR.Add(M1.C3D(Length / 2 - CoverThk - radius * scale, radius * scale - CoverThk));
            for (int i = 0; i < ArrAlongW.Count; i++)
            {
                double item = ArrAlongW[i];
                bottomPtsR.Add(bottomPtsR[bottomPtsR.Count - 1].C3D(item));
            }
            bottomPtsR.Sort((x, y) => x.X.CompareTo(y.X));
            if (_pileCapPara.N12 != eRebarDia.None)
            {
                RebarPLPloter.CreateRebarPointLine(db, ref ext, eDirection.E_TOP, bottomPtsR, dicNo[12].ToString(), 4, 3, scale, true);
            }
            // 6
            LA = 0;
            bottomPtsR = new List<Point3d>();
            bottomPtsR.Add(M1.C3D(-0.5 * Width + CoverThk + radius * scale, -Height + pileDepth + bottomSapce * (bottomNum - 1) - GeneralRebar.outerDia[_pileCapPara.N1]*0.5));
            for (int i = 0; i < ArrAlongH.Count - 1; i++)
            {
                double item = ArrAlongH[i];
                bottomPtsR.Add(bottomPtsR[bottomPtsR.Count - 1].C3D(0, item));
            }
            bottomPtsR.Sort((x, y) => y.Y.CompareTo(x.Y));
            bottomPtsR.RemoveAt(bottomPtsR.Count - 1);
            RebarPLPloter.CreateRebarPointLine(db, ref ext, eDirection.E_RIGHT, bottomPtsR, dicNo[7].ToString(), 2, 0, scale);
            LA = 0;
            bottomPtsR = new List<Point3d>();
            bottomPtsR.Add(M1.C3D(0.5 * Width - CoverThk - radius * scale, -Height + pileDepth + bottomSapce * (bottomNum - 1) - GeneralRebar.outerDia[_pileCapPara.N1]*0.5));
            //bottomPtsR.Add(M1.C3D(Length / 2 - CoverThk - radius * scale, radius * scale - CoverThk));
            for (int i = 0; i < ArrAlongH.Count - 1; i++)
            {
                double item = ArrAlongH[i];
                bottomPtsR.Add(bottomPtsR[bottomPtsR.Count - 1].C3D(0, item));
            }
            bottomPtsR.Sort((x, y) => y.Y.CompareTo(x.Y));
            bottomPtsR.RemoveAt(bottomPtsR.Count - 1);
            RebarPLPloter.CreateRebarPointLine(db, ref ext, eDirection.E_LEFT, bottomPtsR, dicNo[7].ToString(), 2, 0, scale);

            #endregion

            #region 标注
            List<Point3d> leftPts = new List<Point3d>(), topPts = new List<Point3d>();
            topPts.Add(M1.C3D(-Width / 2));
            topPts.Add(M1.C3D(-Width / 2 + CoverThk + GeneralRebar.outerDia[_pileCapPara.N5] * 0.5));
            //topPts.Add(M1.C3D(Width / 2 - CoverThk - GeneralRebar.outerDia[_N3Dia] / 2));
            topPts.Add(M1.C3D(Width / 2));
            LA = 0;
            for (int i = 0; i < ArrAlongW.Count; i++)
            {
                double item = ArrAlongW[i];
                LA += item;
                //double item = ArrAlongL[i];
                //LA += item;
                topPts.Add(M1.C3D(-Width / 2 + CoverThk + LA + GeneralRebar.outerDia[_pileCapPara.N5] * 0.5));

                //if (i < ArrAlongW.Count - 1)
                //    topPts.Add(M1.C3D(-Width / 2 + CoverThk + LA + GeneralRebar.outerDia[_N3Dia] / 2));
                //else
                //    topPts.Add(M1.C3D(-Width / 2 + CoverThk + LA - 2 * GeneralRebar.outerDia[_N3Dia] / 2));
            }
            topPts.Sort((x, y) => x.X.CompareTo(y.X));

            DimPloter.AddDoubleListDimRotated(db, ref ext, topPts[0].C3D(0, 10 * scale), topPts, scale, 0, t2bSapceW, ArrowDirection.North, Unit.Millimeter, Unit.Centimeter);

            leftPts.Add(M1.C3D(-Width / 2, 0));
            leftPts.Add(M1.C3D(-Width / 2, -CoverThk - GeneralRebar.outerDia[_pileCapPara.N1] * 0.5));
            leftPts.Add(M1.C3D(-Width / 2, -Height + pileDepth - GeneralRebar.outerDia[_pileCapPara.N1] * 0.5));
            leftPts.Add(M1.C3D(-Width / 2, -Height));
            for (int i = 1; i < bottomNum; i++)
            {
                leftPts.Add(M1.C3D(-Width / 2, -Height + pileDepth - GeneralRebar.outerDia[_pileCapPara.N1] * 0.5 + bottomSapce * i));
            }

            LA = 0;
            for (int i = 0; i < ArrAlongH.Count; i++)
            {
                double item = ArrAlongH[i];
                LA += item;

                leftPts.Add(M1.C3D(-Width / 2, -Height + pileDepth + bottomSapce * (bottomNum - 1) + LA - GeneralRebar.outerDia[_N1Dia] / 2));

            }
            leftPts.Sort((x, y) => x.Y.CompareTo(y.Y));

            List<Point3d> listBottom = new List<Point3d>();
            for (int i = 0; i < bottomNum + 2; i++)
            {
                listBottom.Add(leftPts[i]);
            }
            DimPloter.AddListDimRotated(db, ref ext, leftPts[0].C3D(-8 * scale), listBottom, scale, 90, 1, Unit.Millimeter, Unit.Centimeter);
            DimPloter.AddListDimRotated(db, ref ext, leftPts[0].C3D(-8 * scale),
                 new List<Point3d>() { leftPts[bottomNum + 1], leftPts[leftPts.Count - 4] }, scale, 90, sideSapce, Unit.Millimeter, Unit.Centimeter);
            DimPloter.AddListDimRotated(db, ref ext, leftPts[0].C3D(-8 * scale),
                new List<Point3d>() { leftPts[leftPts.Count - 1], leftPts[leftPts.Count - 2], leftPts[leftPts.Count - 4] }, scale, 90, 1, Unit.Millimeter, Unit.Centimeter);
            DimPloter.AddListDimRotated(db, ref ext, leftPts[0].C3D(-8 * scale - 5 * scale),
                new List<Point3d>() { M1.C3D(0, -Height), M1.C3D() }, scale, 90, 1, Unit.Millimeter, Unit.Centimeter);

            #endregion
        }

        /// <summary>
        /// 绘制Plan
        /// </summary>
        /// <param name="db"></param>
        /// <param name="ext"></param>
        /// <param name="insertPoint"></param>
        /// <param name="scale"></param>
        public void PlotPlan(ref Database db, out Extents2d ext, Point2d insertPoint, int scale)
        {
            ext = new Extents2d(insertPoint, insertPoint);
            TextPloter.AddTitle(db,insertPoint.C2D(0, 0), ref ext, "平面", string.Format("(1:{0:G})", scale),  scale);
            //TextPloter.PrintScaleText(db, insertPoint.C2D(Width / 4, 0), "1/2 SECTION F-F", string.Format("(1:{0:G})", scale), ref ext, scale, Extensions.curFont);
            Point2d CT = insertPoint;
            Point2d M1 = CT.C2D(0, -20 * scale);

            PLPloter.AddPloy4(db, M1, 0.5 * Length, 0.5 * Length, Width, ref ext,"H细线");

            List<List<double>> ArrAlongMainReinforcement = new List<List<double>>();
            List<Point3d> listPt = new List<Point3d>();
            listPt.Add(new Point3d(60, 60, 0));
            listPt.Add(new Point3d(560, 60, 0));
            listPt.Add(new Point3d(60, 560, 0));
            listPt.Add(new Point3d(560, 560, 0));
            RebarPLPloter.CreatePlotElevationEF(db, ref ext, M1.C2D(-0.5 * Length),
                ArrAlongL, ArrAlongW, ArrAlongWE, ArrAlongLE, listPt, pileDia, Length, Width, radius, CoverThk, scale,dicNo, GeneralRebar.outerDia[_pileCapPara.N5],t2bSapceW,t2bSapceL);

            #region 编号
            List<double> wList = new List<double>();
            for (int i = 0; i < ArrAlongW.Count; i++)
            {
                wList.Add(ArrAlongW[i]);
            }
            RebarPLPloter.CreateLineArrowDB(db, ref ext, M1.C3D(Length / 6, -CoverThk-2*radius*scale), ArrowDirection.North, wList, new List<double>(), "1", scale, true, 5);

            wList.Clear();
            for (int i = 0; i < ArrAlongL.Count; i++)
            {
                wList.Add(ArrAlongL[i]);
            }
            RebarPLPloter.CreateLineArrowDB(db, ref ext, M1.C3D(-Length / 2 + CoverThk + 2 * radius * scale, -Width*2/5), ArrowDirection.West,new List<double>(), wList, "2", scale, true, 8);
            #endregion
        }

        /// <summary>
        /// 绘制钢筋
        /// </summary>
        /// <param name="db"></param>
        /// <param name="insertPoint"></param>
        /// <param name="ext"></param>
        public void RendeDetail(ref Database db, Point2d insertPoint, out Extents2d ext, 
            System.Data.DataTable dt1, System.Data.DataTable dt2,double scale = 50)
        {
            ext = new Extents2d(insertPoint, insertPoint);
            Point2d CT = insertPoint;
            Point2d M1 = CT.C2D(0, -2 * scale);

            //PLPloter.AddPloy4(db, ref ext, M1, 0.5 * 10, 0.5 * 10, 20);

            // 查询数据
            //string selectString = string.Format("SELECT * FROM span_tbl where Name='{0}'", SpName);
            //var consetr = string.Format("data source=cdb-2ashfo5g.bj.tencentcdb.com;port=10033;user id=wyz;password=wang1234;DataBase=nep2021;charset=utf8"); ;// string.Format("server={0};port={3};user id={1};password={2};charset=utf8;database={4}", address, user, password, port,database);
            //System.Data.DataTable dt = SRBMain.MySqlHelper.(consetr, selectString, System.Data.CommandType.Text);

            // 绘制表格
            List <string> list = new List<string>();
            list.Add("编号");
            list.Add("直径\\P(mm)");
            list.Add("大样");
            list.Add("单根长\\P(cm)");
            list.Add("根数");
            list.Add("总长\\P(m)");
            list.Add("单位重\\P(kg/m)");
            list.Add("总重\\P(kg)");
            //list.Add("小计(kg)");
            double height = 0;
            double width = 0;
            ModelTablePloter.DrawCapRebarTable(db, ref ext, M1.C3D(-0.5 * Width + CoverThk), dt1, list, dt1.Rows.Count + 1, list.Count, ref height, ref width, Extensions.curFont, scale, true);
            double ActualWidth = 0, ActualHeight=0;
            MText txt = TextPloter.GetTextActualWidth(db, "承台钢筋明细表", scale,out ActualWidth, out ActualHeight,5);
            TextPloter.AddMText(db,M1.C3D(-0.5 * Width + CoverThk + (width - ActualWidth) / 2, ActualHeight + scale * 2), ref ext, "承台钢筋明细表", scale, 5, ActualWidth+5, Extensions.curFont);

            List<string> list1 = new List<string>();
            list1.Add("名称及规格");
            list1.Add("名称及规格");
            list1.Add("单位");
            list1.Add("总重");
            list1.Add("合计");
            double height1 = 0;
            double width1 = 0;
            txt = TextPloter.GetTextActualWidth(db, "承台材料数量表(全桥"+_pileCapPara.structureNumber+"个)", scale,out ActualWidth,out ActualHeight,5);
            ModelTablePloter.DrawCapMaterialsTable(db, ref ext, M1.C3D(-0.5 * Width + CoverThk, -height - ActualHeight * 3), dt2, list1, dt2.Rows.Count + 1, list1.Count, ref height1, ref width1, Extensions.curFont, scale);
            TextPloter.AddMText(db,M1.C3D(-0.5 * Width + CoverThk + (width1 - ActualWidth) / 2, -height - ActualHeight * 2 + scale * 2), ref ext, "承台材料数量表(全桥" + _pileCapPara.structureNumber + "个)", scale, 5, ActualWidth+2*scale, Extensions.curFont);

            // 文字
            string text = "注";
            Point3d p1 = M1.C3D(-0.5 * Width + CoverThk + width1 + scale * 5, -height - ActualHeight * 3);
            TextPloter.AddMText(db,p1, ref ext, text, scale, 2.5, 50, Extensions.curFont);

            text = @"1.本图尺寸除钢筋直径以毫米计外，余均会以厘米为单位。
2.钢筋按尺寸9m长计算连接器数量。
3.施工承台时应注意预埋墩身钢筋。
4.本图适用于XX号墩";
            Point3d p2 = M1.C3D(-0.5 * Width + CoverThk + width1 + scale * 5, -height - ActualHeight * 3-4.5*scale);
            TextPloter.AddMText(db,p2, ref ext, text, scale, 2.5, 50* scale, Extensions.curFont);


        }

        public override DBObjectCollection Render()
        {
            var f = new DBObjectCollection();

            return f;
        }
    }
}
